-
Notifications
You must be signed in to change notification settings - Fork 559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
autodoc: Change dictionary sort order #22441
Conversation
To review this pull request, I built blead through
Grepping the two generated files (as described below), I couldn't find any
If I grepped for
... then took a
... which appears to meet your objective.
Using the search procedure described above, I found in blead:
... while in the branch I found:
So there was no change in |
c719da9
to
32eaf9d
Compare
Sorry for my glib description. I forgot that this retained the existing sort order of numbers where the come after letters. I changed the commit message to give real examples of the things that did change |
autodoc.pl
Outdated
# Convert all digit sequences to same length with leading zeros, so for | ||
# example, 8 will compare less than 16 (using a fill length value that | ||
# should be longer than any sequence in the input). | ||
# Convert all digit sequences to be the same length with leading zeros, so | ||
# that, for example '8' will sort before '16' (using a fill length value | ||
# that should be longer than any sequence in the input). | ||
$a =~ s/(\d+)/sprintf "%06d", $1/ge; | ||
$b =~ s/(\d+)/sprintf "%06d", $1/ge; | ||
|
||
# Translate any underscores and digits so they compare after all Unicode | ||
# characters | ||
$a =~ tr[_0-9]/\x{110000}-\x{11000A}/; | ||
$b =~ tr[_0-9]/\x{110000}-\x{11000A}/; | ||
# Translate any underscores so they sort lowest. This causes 'word1_word2' | ||
# to sort before 'word1word2' for all words. | ||
# And translate any digits so they come after anything else. This causes | ||
# digits to sort highest) | ||
$a =~ tr[_0-9]/\0\x{110000}-\x{110009}/; | ||
$b =~ tr[_0-9]/\0\x{110000}-\x{110009}/; | ||
|
||
# Then move leading underscores to the end, translating them to above | ||
# everything else. This causes '_word_' to compare just after 'word_' | ||
$a .= "\x{11000A}" x length $1 if $a =~ s/ ^ (\0+) //x; | ||
$b .= "\x{11000A}" x length $1 if $b =~ s/ ^ (\0+) //x; | ||
|
||
use feature 'state'; | ||
# Modify \w, \W to reflect the changes. | ||
state $ud = '\x{110000}-\x{11000A}'; # xlated underscore, digits | ||
state $w = "\\w$ud"; # new \w string | ||
use feature 'state'; | ||
state $w = "\\w\0\x{110000}-\x{11000A}"; # new \w string | ||
state $mod_w = qr/[$w]/; | ||
state $mod_W = qr/[^$w]/; | ||
|
||
# Only \w for initial comparison | ||
my $a_only_word = uc($a =~ s/$mod_W//gr); | ||
my $b_only_word = uc($b =~ s/$mod_W//gr); | ||
|
||
# And not initial nor interior underscores nor digits (by squeezing them | ||
# out) | ||
my $a_stripped = $a_only_word =~ s/ (*atomic:[$ud]+) (*pla: $mod_w ) //grxx; | ||
my $b_stripped = $b_only_word =~ s/ (*atomic:[$ud]+) (*pla: $mod_w ) //grxx; | ||
# Strip out \W. | ||
my $a_stripped = $a =~ s/$mod_W//gr; | ||
my $b_stripped = $b =~ s/$mod_W//gr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All this duplicated code between $a
and $b
could go into a function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
This makes this more in line with Data::Dumper sorting. upper/lower case continues to not matter, and numbers continue to come after letters, so that ckWARN2() comes after plain ckWARN(). It changes non-leading underscores to come before letters, so that ck_warner comes before ckWARN. And it changes so leading underscores come after non-leading, so that aMY_CXT and aMY_CXT_ come before _aMY_CXT.
32eaf9d
to
15b7330
Compare
This makes this more in line with Data::Dumper sorting.
upper/lower case continues to not matter, and numbers continue to come after letters, so that
ckWARN2()
comes after plainckWARN()
.It changes non-leading underscores to come before letters, so that
ck_warner
comes beforeckWARN
.And it changes so leading underscores come after non-leading, so that
aMY_CXT
andaMY_CXT_
come before_aMY_CXT